<% layout('/layouts/default.html', {title: '员工管理', libs: ['dataGrid']}){ %>
 <div class="card bd-0">
    <div class="card-header d-flex align-items-start justify-content-between box-header">
      <div class="pt-1">员工管理</div>
      <div class="d-flex">
          <button type="button" id="btnSearch" title="查询" class="btn btn-xs btn-default"><i class="fa fa-filter"></i>查询</button>
          <a href="${ctx}/sys/empUser/form?op=add" class="btn btn-xs btn-primary mg-l-10 btnTool" title="新增员工"><i class="fa fa-plus"></i>新增</a>
      </div>
    </div>
    <div class="card-body pd-10">
       <#form:form id="searchForm" model="${empUser}" action="${ctx}/sys/empUser/listData" method="post" class="form-horizontal"
					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
        <#form:hidden id="officeCode" name="employee.officeCode"/>
		<div class="form-group">
          <div class="input-group wd-250">
            <div class="input-group-prepend">
              <span class="input-group-text">登录账号</span>
            </div>
            <#form:input name="username" class="form-control" placeholder="输入登录账号" />
          </div>
        </div>
		<div class="form-group">
			<div class="input-group">
				<div class="input-group-prepend">
					<span class="input-group-text">状态</span>
         		</div>
         		<div class="wd-100">
					<#form:select path="status" dictType="sys_search_status" blankOption="true" blankOptionLabel="请选择" class="form-control select2"/>
         		</div>
			</div>
		</div>
		<div class="form-group">
			<button type="submit" class="btn btn-primary btn-sm">查询</button>
			<button type="reset" class="btn btn-default btn-sm">重置</button>
		</div>
		</#form:form>
		<table id="dataGrid"></table>
		<div id="dataGridPage"></div>
    </div>
  </div>
<% } %>
<script>
//初始化DataGrid对象
$('#dataGrid').dataGrid({
	searchForm: $("#searchForm"),
	columnModel: [
		{header:'登录账号', name:'username', index:'username', width:200, align:"center", frozen:true, formatter: function(val, obj, row, act){
			return '<a href="${ctx}/sys/empUser/form?userCode='+row.userCode+'&op=edit" class="btnList" data-title="编辑用户">'+(val||row.id)+'</a>';
		}},
		{header:'用户昵称', name:'nickname', index:'nickname', width:200, align:"center"},
		{header:'员工姓名', name:'employee.empName', index:'emp_name', width:200, align:"center"},
		{header:'所属公司', name:'employee.companyName', index:'company_name', width:200, sortable:false,align:"center"},
		{header:'所属机构', name:'employee.officeName', index:'office_name', width:200, sortable:false,align:"center"},
		{header:'电子邮箱', name:'email', index:'email', width:200, align:"center"},
		{header:'手机号码', name:'mobile', index:'mobile', width:200, align:"center"},
		{header:'办公电话', name:'phone', index:'phone', width:200, align:"center"},
		{header:'更新时间', name:'updateTime', index:'update_time', width:200, align:"center" },
		{header:'状态', name:'status', index:'status', width:140, align:"center", formatter: function(val, obj, row, act){
			return js.getDictLabel(${@DictUtils.getDictListJson('sys_status')}, val, '未知', true);
		}},
		{header:'操作', name:'actions', width:110, fixed:true, sortable:false, title:false, formatter: function(val, obj, row, act){
			var actions = [];
			<% if(expIf("hasAuthority('sys:user:edit')")){ %>
				actions.push('<a href="${ctx}/sys/empUser/form?userCode='+row.userCode+'&op=edit" class="btnList" title="编辑用户"><i class="la la-edit"></i></a>&nbsp;');
			<% } %>
			<% if(expIf("hasAuthority('sys:user:updateStatus')")){ %>
				if (row.status == Global.STATUS_NORMAL){
					actions.push('<a href="${ctx}/sys/empUser/disable?userCode='+row.userCode+'" class="btnList" title="停用用户" data-confirm="确认要停用该用户吗？"><i class="la la-minus-circle"></i></a>&nbsp;');
				}
				if (row.status == Global.STATUS_DISABLE){
					actions.push('<a href="${ctx}/sys/empUser/enable?userCode='+row.userCode+'" class="btnList" title="启用用户" data-confirm="确认要启用该用户吗？"><i class="la la-check-circle"></i></a>&nbsp;');
				}
			<% } %>
			<% if(expIf("hasAuthority('sys:user:edit')")){ %>
				actions.push('<a href="${ctx}/sys/empUser/delete?userCode='+row.userCode+'" class="btnList" title="删除用户" data-confirm="确认要删除该用户吗？"><i class="la la-trash"></i></a>&nbsp;');
			<% } %>
			
			actions.push('<a href="#" class="dropdown-link" data-toggle="dropdown" ><i class="la la-ellipsis-v"></i></a>');
			actions.push('<div class="dropdown-menu dropdown-menu-right">');
			<% if(expIf("hasAuthority('sys:user:authRole')")){ %>
					actions.push('<a href="${ctx}/sys/empUser/form?userCode='+row.userCode+'&op=auth" class="dropdown-item btnList" title="用户设置权限"><i class="la la-cube"></i> 设置权限</a>');
			<% } %>
			<% if(expIf("hasAuthority('sys:user:authDataScope')")){ %>
					actions.push('<a href="${ctx}/sys/empUser/formAuthDataScope?userCode='+row.userCode+'" class="dropdown-item btnList" title="用户分配数据权限"><i class="la la-cogs"></i> 数据权限</a>');
			<% } %>
			<% if(expIf("hasAuthority('sys:user:resetpwd')")){ %>
					actions.push('<a href="${ctx}/sys/empUser/resetpwd?userCode='+row.userCode+'" class="dropdown-item btnList" title="用户密码重置" data-confirm="确认要将该用户密码重置到初始状态吗？"><i class="la la-mail-reply"></i> 重置密码</a>');
			<% } %>
			actions.push('</div>');
			
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});
</script>
</body></html>